<template>
<!-- 口径成员页面 -->
  <div>
    <el-row class="caliberMembers container">
      <el-col :span="24" class="content-left">
          <!-- 操作区域 -->
         <upper-template @search = "searchFunc" exportIcon @clear= "searchForm.caliberProjectCode='',searchForm.treeTypeName='',searchForm.moduleCode = ''">
           <!-- 操作按钮区 -->
           <template slot="buttonArea">
             <el-button type="normal"  @click="addFunc">新增</el-button>
            <el-button type="normal" @click="editFunc">编辑</el-button>
            <el-button type="normal" @click="deleteFunc">删除</el-button>
            <el-button type="normal" @click="configFun">口径定义</el-button>
           </template>
           <!-- 搜索区 -->
           <template slot="searchArea">
               <el-form
                    :model="searchForm"
                    ref="searchForm"
                    label-width="80px"
                    label-position="right"
                    size="mini"
                  >
                    <el-form-item label="方案编码：">
                      <el-input v-model="searchForm.caliberProjectCode" style="width:150px"></el-input>
                    </el-form-item>
                    <el-form-item label="方案名称：" prop="caliberProjectName">
                      <el-input v-model="searchForm.treeTypeName" style="width:150px"></el-input>
                    </el-form-item>
                    <el-form-item label="所属模块：	" prop="caliberProjectName">
                      <el-select
                        v-model="searchForm.moduleCode"
                        placeholder="请选择"
                        style="width:150px"
                        clearable=""
                      >
                      <el-option v-for="item in moduleList"
                       :key="item.value"
                       :value="item.value"
                       :label="item.label"
                       ></el-option>
                        
                      </el-select>
                    </el-form-item>
                  </el-form>
           </template>
           <!-- 显示隐藏区 -->
           <template slot="columnHide">
               <el-checkbox-group v-model="checkList">
                    <el-checkbox
                      v-for="item in textData"
                      :label="item.label"
                      :key="item.prop"
                      :disabled="item.hideDisable"
                    >{{item.label}}</el-checkbox>
                  </el-checkbox-group>
           </template>
          </upper-template>

        <el-table ref="multipleTable" :data="tableData" style="width: 100%">
          <el-table-column width="55" type="selection" fixed="left"></el-table-column>
          <el-table-column
            v-for="(item, key) in showData"
            :key="key"
            :prop="item.prop"
            :label="item.label"
            :show-overflow-tooltip="true"
            :render-header="item.render"
            :sortable="item.sortable"
            :formatter="item.formatter"
          ></el-table-column>
          <!-- <el-table-column label="操作" width="180" fixed="right"></el-table-column> -->
        </el-table>
        <pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="1"
          @refresh = "searchFFunc"
          :page-size="15"
          :total="400"
        ></pagination>
      </el-col>
    </el-row>
    <el-dialog v-dialogDrag title="口径方案" :visible.sync="addOrEdit" width="514px" top="2%">
      <el-form
        :model="saveForm"
        ref="addTreeForm"
        label-width="130px"
        label-position="left"
        :rules="saveFormRules"
      >
        <el-form-item label="口径方案编码：" prop="caliberProjectCode">
          <el-input
            v-model="saveForm.caliberProjectCode"
            :disabled="saveFlg!=1"
            placeholder="请输入口径方案编码"
          ></el-input>
        </el-form-item>
        <el-form-item label="口径方案名称：" prop="caliberProjectName">
          <el-input v-model="saveForm.caliberProjectName" 
            placeholder="请输入口径方案名称"
          ></el-input>
        </el-form-item>
        <el-form-item label="所属模块：" prop="moduleCode">
          <el-select v-model="saveForm.moduleCode" placeholder="请选择所属模块" style="width:100%">
             <el-option v-for="item in moduleList"
                       :key="item.value"
                       :value="item.value"
                       :label="item.label"
                       ></el-option>
                        
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button  @click="addOrEdit = false">确 定</el-button>
        <el-button @click="addOrEdit = false">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 口径定义弹窗 -->
    <el-dialog v-dialogDrag title="口径定义" :visible.sync="isConfigDialog" width="60%" top="2%">
           <el-row :gutter="20">
            <el-col  :span="14">
           <upper-template @search = "searchFFunc" exportIcon importIcon :configIcon="false" @clear= "searchFF.caliberName='',searchFF.caliberCode=''">
           <!-- 操作按钮区 -->
           <template slot="buttonArea">
            <el-button  @click="addFuncInner">新增</el-button>
            <el-button  @click="editFuncInner">编辑</el-button>
            <el-button  @click="deleteFuncInner">删除</el-button>
           </template>
           <!-- 搜索区 -->
           <template slot="searchArea">
               <el-form
                    :model="searchFF"
                    ref="searchFF"
                    label-width="80px"
                    label-position="right"
                    size="mini"
                  >
                    <el-form-item label="口径编码：" prop="caliberCode">
                      <el-input v-model="searchFF.caliberCode"
                       placeholder="请输入口径编码" style="width:150px"></el-input>
                    </el-form-item>
                    <el-form-item label="口径名称：" prop="caliberName">
                      <el-input v-model="searchFF.caliberName" style="width:150px"></el-input>
                    </el-form-item>
                  </el-form>
           </template>
          </upper-template>
          <el-table
            ref="definitionTable"
            :data="definitionTableData"
            style="width: 100%"
            @row-click="getConfigTree"
          >
            <el-table-column width="55" type="selection" fixed="left"></el-table-column>
            <el-table-column
              v-for="(item, key) in definitionConfig"
              :key="key"
              :prop="item.prop"
              :label="item.label"
              :align="item.align"
              :show-overflow-tooltip="true"
              :render-header="item.render"
              :sortable="item.sortable"
              :formatter="item.formatter"
              header-align="center"
              :width="item.width"
            ></el-table-column>
          </el-table>
          <pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="searchFF.page"
            :pager-count="5"
            :total="40"
          ></pagination>
        </el-col>
        <el-col  :span="10" class="content-right">
          <el-row class="title">
            <span class="gun"></span>
            业务口径定义规则 - {{RTitle}}
          </el-row>
          <el-row style="padding:10px 0 ">
            <el-button @click="addRuleData">新增</el-button>
          </el-row>
          <el-row>
            <!-- 业务口径规则表 -->
            <el-table :data="kjRuleTable">
              <el-table-column fixed="left" width="50">
                <template slot-scope="scope">
                  {{scope.$index==0?"":"或"}}
                </template>
              </el-table-column>
              <el-table-column>
                <template slot-scope="scope">
                  <div v-for="(item,i) in scope.row.caliberRuleTermList" :key="scope.$index+''+i">
                    <span style="display:inline-block;width:80px">{{item.rullDictName}}</span>
                    <span style="display:inline-block;width:30px;color:#096dd9">包含</span>
                    <span style="display:inline-block;width:160px">{{item.rullValName}}</span>
                  </div>
                </template>
              </el-table-column>
              <el-table-column width="80">
                <template slot-scope="scope" >
                  <el-link @click="editRuleData(scope.row)" style="margin-right:10px">编辑</el-link>
                  <el-link @click="deleteRuleData(scope.row)">删除</el-link>
                </template>
              </el-table-column>
            </el-table>
          </el-row>
        </el-col>
      </el-row>
         <!-- 口径定义新增/编辑（左表）弹窗 -->
      <el-dialog v-dialogDrag width="35%" :title="(saveFlgInner==1?'添加':'修改')+'业务口径表信息'" :visible.sync="isScopeDialog" append-to-body>
          <el-form
        :model="saveFormInner"
        ref="saveFormInner"
        label-width="130px"
        label-position="left"
        :rules="saveFormInnerRules"
      >
        <el-form-item label="口径编码：" prop="caliberCode">
          <el-input
            v-model="saveFormInner.caliberCode"
            :disabled="saveFlgInner!=1"
            placeholder="请输入口径编码"
          ></el-input>
        </el-form-item>
        <el-form-item label="口径名称：" prop="caliberName">
          <el-input v-model="saveFormInner.caliberName" 
            placeholder="请输入口径名称"
          ></el-input>
        </el-form-item>
        <el-form-item label="所属口径方案：" prop="caliberProjectCode">
          <el-select v-model="saveFormInner.caliberProjectCode"  style="width:100%" disabled>
             <el-option v-for="item in moduleList"
                       :key="item.value"
                       :value="item.value"
                       :label="item.label"
                       ></el-option>
                        
          </el-select>
        </el-form-item>
      </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button  @click="isScopeDialog = false">确 定</el-button>
          <el-button @click="isScopeDialog = false">取 消</el-button>
        </div>
      </el-dialog>
        <!-- 口径定义规则（右表）弹窗 -->
      <el-dialog v-dialogDrag width="60%" title="口径定义规则" :visible.sync="ruleDefShow" append-to-body>
          <rule-def :dataList="ruleDefList"></rule-def>
        <div slot="footer" class="dialog-footer">
          <el-button  @click="saveRuleDefFunc">确 定</el-button>
          <el-button @click="ruleDefShow = false">取 消</el-button>
        </div>
      </el-dialog>
      <div slot="footer" class="dialog-footer">
        <!-- 口径定义的底部 -->
        </div>
    </el-dialog>
  </div>
</template>

<script>
import { publicManage } from "@/api/index";
import upperTemplate from "@/components/upperTemplate.vue"
import ruleDef from "./components/ruleDef"
import moment from 'moment'
export default {
  components:{upperTemplate,ruleDef},
  data() {
    return {
      saveFlg: 1,
      saveFlgInner:1,
      addOrEdit: false,
      isConfigDialog: false,
      serachMore: false, // 搜索条件显影
      isScopeDialog:false,// 口径定义表新增编辑弹窗
      ruleDefShow:false,// 口径定义规则复杂弹窗
      RTitle: "",
      searchForm: {},
      searchFF: {
        caliberName: "",
        caliberCode: "",
        page:1,size:15
      },
      // 所属模块字典list
      moduleList:[
        {label:"FTP",value:"FTP"},
        {label:"CA",value:"CA"},
        {label:"EC",value:"EC"},
        {label:"LPM",value:"LPM"},
      ],
      saveForm: {},
      saveFormInner:{},
      checkList: [],
      //   列属性字段配置 -
      textData: [
        { prop: "caliberProjectCode", label: "口径方案编码", align: "left" ,hideDisable:true},
        { prop: "caliberProjectName", label: "口径方案名称", align: "left" ,hideDisable:true},
        { prop: "moduleCode", label: "所属模块 ", align: "left" ,sortable:true,hideDisable:true},
        { prop: "creator", label: "创建人", align: "left" },
        { prop: "createdTm", label: "创建时间 ", align: "right",formatter:(row)=>moment(row.createdTm).format('YYYY-MM-DD'),},
        { prop: "modifier", label: "修改人 ", align: "left"},
        { prop: "modifiedTm", label: "修改时间 ", align: "right",formatter:(row)=>moment(row.createdTm).format('YYYY-MM-DD'), }
      ],
      textData1:[
        { prop: "caliberCode", label: "口径编码 ",hideDisable:true},
        { prop: "caliberName", label: "口径名称 ", hideDisable:true },
        { prop: "caliberProject.caliberProjectName", label: "口径方案 ", hideDisable:true },
      ],
      //   列属性字段配置 - 口径定义表
      definitionConfig: [
        { prop: "caliberCode", label: "口径编码 ", align: "right",sortable:true,width:100},
        { prop: "caliberName", label: "口径名称 ", align: "left" },
        { prop: "caliberProject.caliberProjectName", label: "口径方案 ", align: "left" },
      ],
      // 口径定义表弹窗右侧
      kjRuleTable:[
        {"creator":null,"createdTm":null,"modifier":null,"modifiedTm":null,"caliberRullCode":"VP_ALM_COA10003001","caliberRullName":null,"caliberCode":"10003","caliberProjectCode":"VP_ALM_COA","rullDictCode":null,"addFlag":null,"conditionFlag":null,"sql":" (  ( productCd in  ('0101','01010101','01010201','01010301','01010401','01010402','01010403','01010501','01010502','01010503','01010505','01010506','01010507','01010508','01010509','01010510','01010511','01010512','01010513','01010514','01010515','01010516','01010517','01010518','01010519','01010601','01010602','01010603','01010604','01010605','01010606','01010607','01010608','01010609','01010610','01010611','01010612','01010613','01010614','01010615','01010616','01010617','01010618','01010619','01010620','01010621','01010622','01010623','01010624','01010625','01010626','01010627','01010628','01010629','01010630','01010631','01010632','01010633','01010634','01010635','01010636','01010701','01010702','01010703','01010704','01010705','01010706','01010801','01011001','01011002','01011003','01011004','01011005','01011101','01011102','01011103','01011104')  ) and ( 001 in   ( 333 )   )  )","rullSeq":"001","caliberRuleTermList":[{"creator":null,"createdTm":null,"modifier":null,"modifiedTm":null,"rullTermCode":"CT20190619000002","caliberRullCode":"VP_ALM_COA10003001","caliberCode":"10003","caliberProjectCode":"VP_ALM_COA","rullDictCode":"productCd","rullDictName":"产品","addFlag":null,"conditionFlag":"in","rullValTree":"1","rullVal":"0101","rullValName":"对公贷款","rullAllVal":"0001","sql":" ( productCd in  ('0101','01010101','01010201','01010301','01010401','01010402','01010403','01010501','01010502','01010503','01010505','01010506','01010507','01010508','01010509','01010510','01010511','01010512','01010513','01010514','01010515','01010516','01010517','01010518','01010519','01010601','01010602','01010603','01010604','01010605','01010606','01010607','01010608','01010609','01010610','01010611','01010612','01010613','01010614','01010615','01010616','01010617','01010618','01010619','01010620','01010621','01010622','01010623','01010624','01010625','01010626','01010627','01010628','01010629','01010630','01010631','01010632','01010633','01010634','01010635','01010636','01010701','01010702','01010703','01010704','01010705','01010706','01010801','01011001','01011002','01011003','01011004','01011005','01011101','01011102','01011103','01011104')  ) ","termSeq":"1","rullDictVal":"('0101','01010101','01010201','01010301','01010401','01010402','01010403','01010501','01010502','01010503','01010505','01010506','01010507','01010508','01010509','01010510','01010511','01010512','01010513','01010514','01010515','01010516','01010517','01010518','01010519','01010601','01010602','01010603','01010604','01010605','01010606','01010607','01010608','01010609','01010610','01010611','01010612','01010613','01010614','01010615','01010616','01010617','01010618','01010619','01010620','01010621','01010622','01010623','01010624','01010625','01010626','01010627','01010628','01010629','01010630','01010631','01010632','01010633','01010634','01010635','01010636','01010701','01010702','01010703','01010704','01010705','01010706','01010801','01011001','01011002','01011003','01011004','01011005','01011101','01011102','01011103','01011104')"},{"creator":null,"createdTm":null,"modifier":null,"modifiedTm":null,"rullTermCode":"CT20190619000003","caliberRullCode":"VP_ALM_COA10003001","caliberCode":"10003","caliberProjectCode":"VP_ALM_COA","rullDictCode":"001","rullDictName":"利率类型","addFlag":"and","conditionFlag":"in","rullValTree":"2","rullVal":"333","rullValName":"333-固定利率","rullAllVal":"TR_ALM_001","sql":"and ( 001 in   ( 333 )   ) ","termSeq":"2","rullDictVal":" ( 333 ) "}]},{"creator":null,"createdTm":null,"modifier":null,"modifiedTm":null,"caliberRullCode":"VP_ALM_COA10003002","caliberRullName":null,"caliberCode":"10003","caliberProjectCode":"VP_ALM_COA","rullDictCode":null,"addFlag":"OR","conditionFlag":null,"sql":" (  ( productCd in   ( 01020112 )   )  )","rullSeq":"002","caliberRuleTermList":[{"creator":null,"createdTm":null,"modifier":null,"modifiedTm":null,"rullTermCode":"CT20190619000004","caliberRullCode":"VP_ALM_COA10003002","caliberCode":"10003","caliberProjectCode":"VP_ALM_COA","rullDictCode":"productCd","rullDictName":"产品","addFlag":null,"conditionFlag":"in","rullValTree":"2","rullVal":"01020112","rullValName":"01020112-宜信公司合作贷款","rullAllVal":"0001","sql":" ( productCd in   ( 01020112 )   ) ","termSeq":"1","rullDictVal":" ( 01020112 ) "}]},{"creator":null,"createdTm":null,"modifier":null,"modifiedTm":null,"caliberRullCode":"VP_ALM_COA10003003","caliberRullName":null,"caliberCode":"10003","caliberProjectCode":"VP_ALM_COA","rullDictCode":null,"addFlag":"OR","conditionFlag":null,"sql":" (  ( GeneralLedger in  ('130304','13030401','13030402')  )  )","rullSeq":"003","caliberRuleTermList":[{"creator":null,"createdTm":null,"modifier":null,"modifiedTm":null,"rullTermCode":"CT20190619000005","caliberRullCode":"VP_ALM_COA10003003","caliberCode":"10003","caliberProjectCode":"VP_ALM_COA","rullDictCode":"GeneralLedger","rullDictName":"科目","addFlag":null,"conditionFlag":"in","rullValTree":"1","rullVal":"130304","rullValName":"贷款-小企业信贷中心专项短期贷款","rullAllVal":"0003","sql":" ( GeneralLedger in  ('130304','13030401','13030402')  ) ","termSeq":"1","rullDictVal":"('130304','13030401','13030402')"}]}
      ],
      saveFormRules: {
        caliberProjectCode: [
          { required: true, message: "请输入口径方案编码", trigger: "blur" }
        ],
        caliberProjectName: [
          { required: true, message: "请输入口径方案名称", trigger: "blur" }
        ],
        moduleCode: [
          { required: true, message: "请选择所属模块", trigger: "blur" }
        ]
      },
      saveFormInnerRules:{
         caliberCode: [
          { required: true, message: "请输入口径编码", trigger: "blur" }
        ],
        caliberName: [
          { required: true, message: "请输入口径名称", trigger: "blur" }
        ],
        caliberProjectCode: [
          { required: true, message: "请选择所属方案", trigger: "blur" }
        ]
      },
      treeData: [],
      definitionTableData: [
        {
          creator: "sys",
          createdTm: 1545873493000,
          modifier: null,
          modifiedTm: null,
          caliberCode: "10001",
          caliberName: "现金",
          caliberProject: {
            creator: "sys",
            createdTm: 1545823874000,
            modifier: "农发总行管理员",
            modifiedTm: 1595469069877,
            caliberProjectCode: "VP_ALM_COA",
            caliberProjectName: "泛鹏银行资产负债账户册",
            moduleCode: "alm",
            caliberProjectDesc: null
          },
          caliberDesc: null,
          caliberSublevel: "0",
          codeAndName: "10001--现金"
        },
        {
          creator: "sys",
          createdTm: 1545873493000,
          modifier: null,
          modifiedTm: null,
          caliberCode: "10002",
          caliberName: "贵金属",
          caliberProject: {
            creator: "sys",
            createdTm: 1545823874000,
            modifier: "农发总行管理员",
            modifiedTm: 1595469069877,
            caliberProjectCode: "VP_ALM_COA",
            caliberProjectName: "泛鹏银行资产负债账户册",
            moduleCode: "alm",
            caliberProjectDesc: null
          },
          caliberDesc: null,
          caliberSublevel: "0",
          codeAndName: "10002--贵金属"
        },
        {
          creator: "sys",
          createdTm: 1545873493000,
          modifier: null,
          modifiedTm: null,
          caliberCode: "10003",
          caliberName: "单位短期贷款",
          caliberProject: {
            creator: "sys",
            createdTm: 1545823874000,
            modifier: "农发总行管理员",
            modifiedTm: 1595469069877,
            caliberProjectCode: "VP_ALM_COA",
            caliberProjectName: "泛鹏银行资产负债账户册",
            moduleCode: "alm",
            caliberProjectDesc: null
          },
          caliberDesc: null,
          caliberSublevel: "0",
          codeAndName: "10003--单位短期贷款"
        },
        {
          creator: "sys",
          createdTm: 1545873493000,
          modifier: null,
          modifiedTm: null,
          caliberCode: "10004",
          caliberName: "单位中长期贷款",
          caliberProject: {
            creator: "sys",
            createdTm: 1545823874000,
            modifier: "农发总行管理员",
            modifiedTm: 1595469069877,
            caliberProjectCode: "VP_ALM_COA",
            caliberProjectName: "泛鹏银行资产负债账户册",
            moduleCode: "alm",
            caliberProjectDesc: null
          },
          caliberDesc: null,
          caliberSublevel: "0",
          codeAndName: "10004--单位中长期贷款"
        },
        {
          creator: "sys",
          createdTm: 1545873493000,
          modifier: null,
          modifiedTm: null,
          caliberCode: "10005",
          caliberName: "贸易融资",
          caliberProject: {
            creator: "sys",
            createdTm: 1545823874000,
            modifier: "农发总行管理员",
            modifiedTm: 1595469069877,
            caliberProjectCode: "VP_ALM_COA",
            caliberProjectName: "泛鹏银行资产负债账户册",
            moduleCode: "alm",
            caliberProjectDesc: null
          },
          caliberDesc: null,
          caliberSublevel: "0",
          codeAndName: "10005--贸易融资"
        },
        {
          creator: "sys",
          createdTm: 1545873493000,
          modifier: null,
          modifiedTm: null,
          caliberCode: "10006",
          caliberName: "贴现",
          caliberProject: {
            creator: "sys",
            createdTm: 1545823874000,
            modifier: "农发总行管理员",
            modifiedTm: 1595469069877,
            caliberProjectCode: "VP_ALM_COA",
            caliberProjectName: "泛鹏银行资产负债账户册",
            moduleCode: "alm",
            caliberProjectDesc: null
          },
          caliberDesc: null,
          caliberSublevel: "0",
          codeAndName: "10006--贴现"
        },
        {
          creator: "sys",
          createdTm: 1545873493000,
          modifier: null,
          modifiedTm: null,
          caliberCode: "10007",
          caliberName: "单位其他贷款",
          caliberProject: {
            creator: "sys",
            createdTm: 1545823874000,
            modifier: "农发总行管理员",
            modifiedTm: 1595469069877,
            caliberProjectCode: "VP_ALM_COA",
            caliberProjectName: "泛鹏银行资产负债账户册",
            moduleCode: "alm",
            caliberProjectDesc: null
          },
          caliberDesc: null,
          caliberSublevel: "0",
          codeAndName: "10007--单位其他贷款"
        },
        {
          creator: "sys",
          createdTm: 1545873493000,
          modifier: null,
          modifiedTm: null,
          caliberCode: "10008",
          caliberName: "个人短期贷款",
          caliberProject: {
            creator: "sys",
            createdTm: 1545823874000,
            modifier: "农发总行管理员",
            modifiedTm: 1595469069877,
            caliberProjectCode: "VP_ALM_COA",
            caliberProjectName: "泛鹏银行资产负债账户册",
            moduleCode: "alm",
            caliberProjectDesc: null
          },
          caliberDesc: null,
          caliberSublevel: "0",
          codeAndName: "10008--个人短期贷款"
        },
        {
          creator: "sys",
          createdTm: 1545873493000,
          modifier: null,
          modifiedTm: null,
          caliberCode: "10009",
          caliberName: "个人中长期贷款",
          caliberProject: {
            creator: "sys",
            createdTm: 1545823874000,
            modifier: "农发总行管理员",
            modifiedTm: 1595469069877,
            caliberProjectCode: "VP_ALM_COA",
            caliberProjectName: "泛鹏银行资产负债账户册",
            moduleCode: "alm",
            caliberProjectDesc: null
          },
          caliberDesc: null,
          caliberSublevel: "0",
          codeAndName: "10009--个人中长期贷款"
        },
        {
          creator: "sys",
          createdTm: 1545873493000,
          modifier: null,
          modifiedTm: null,
          caliberCode: "10010",
          caliberName: "卡业务",
          caliberProject: {
            creator: "sys",
            createdTm: 1545823874000,
            modifier: "农发总行管理员",
            modifiedTm: 1595469069877,
            caliberProjectCode: "VP_ALM_COA",
            caliberProjectName: "泛鹏银行资产负债账户册",
            moduleCode: "alm",
            caliberProjectDesc: null
          },
          caliberDesc: null,
          caliberSublevel: "0",
          codeAndName: "10010--卡业务"
        }
      ],
      tableData: [
        {
          creator: "sys",
          createdTm: 1597048945879,
          modifier: "sys",
          modifiedTm: 1597052829031,
          caliberProjectCode: "Z0001",
          caliberProjectName: "test口径",
          moduleCode: "alm",
          caliberProjectDesc: null
        },
        {
          creator: "sys",
          createdTm: 1589353401967,
          modifier: "农发总行管理员",
          modifiedTm: 1595468732733,
          caliberProjectCode: "IES_CODE",
          caliberProjectName: "经营计划预算单元树",
          moduleCode: "alm",
          caliberProjectDesc: null
        },
        {
          creator: "sys",
          createdTm: 1565747177260,
          modifier: "sys",
          modifiedTm: 1590052033170,
          caliberProjectCode: "SMART_MODEL",
          caliberProjectName: "智慧模型专用口径",
          moduleCode: "alm",
          caliberProjectDesc: null
        },
        {
          creator: "sys",
          createdTm: 1545823874000,
          modifier: "农发总行管理员",
          modifiedTm: 1595469069877,
          caliberProjectCode: "VP_ALM_COA",
          caliberProjectName: "泛鹏银行资产负债账户册",
          moduleCode: "alm",
          caliberProjectDesc: null
        }
      ],

      // 行内编辑编辑弹窗表单绑定数据
      ruleDefList: [
        {
          creator: null,
          createdTm: null,
          modifier: null,
          modifiedTm: null,
          rullTermCode: null,
          caliberRullCode: null,
          caliberCode: null,
          caliberProjectCode: null,
          rullDictCode: "GeneralLedger",
          rullDictName: "科目",
          addFlag: null,
          conditionFlag: null,
          rullValTree: "1",
          rullVal: null,
          rullValName: "科目树",
          rullAllVal: "0003",
          sql: null,
          termSeq: null,
          rullDictVal: null
        },
        {
          creator: null,
          createdTm: null,
          modifier: null,
          modifiedTm: null,
          rullTermCode: null,
          caliberRullCode: null,
          caliberCode: null,
          caliberProjectCode: null,
          rullDictCode: "GeneralLedger",
          rullDictName: "科目",
          addFlag: null,
          conditionFlag: null,
          rullValTree: "1",
          rullVal: null,
          rullValName: "科目树",
          rullAllVal: "0003",
          sql: null,
          termSeq: null,
          rullDictVal: null
        },
        {
          creator: null,
          createdTm: null,
          modifier: null,
          modifiedTm: null,
          rullTermCode: null,
          caliberRullCode: null,
          caliberCode: null,
          caliberProjectCode: null,
          rullDictCode: "productCd",
          rullDictName: "产品",
          addFlag: null,
          conditionFlag: null,
          rullValTree: "1",
          rullVal: null,
          rullValName: "产品树-全业务",
          rullAllVal: "0001",
          sql: null,
          termSeq: null,
          rullDictVal: null
        }
      ]
    };
  },
  created() {
    this.checkListInit();
  },
  computed: {
    // 展示字段
    showData() {
      let arr = this.textData.map(v => {
        return v.label;
      });
      let valArr = [],
        showData = [];
      // 选中的字段排序
      arr.forEach(element => {
        let flag = false;
        this.checkList.forEach(e => {
          if (e == element) {
            flag = true;
          }
        });
        if (flag) {
          valArr.push(element);
        }
      });
      // 控制表列隐藏显示
      for (let i = 0; i < this.checkList.length; i++) {
        for (let j = 0; j < this.textData.length; j++) {
          if (this.textData[j].label == valArr[i]) {
            let item = { ...this.textData[j] };
            showData.push(item);
          }
        }
      }
      return showData;
    }
  },
  methods: {
    checkListInit() {
      this.checkList = this.textData.map(v => v.label);
    },
    // 点击左侧table获取层级配置口径树
    getConfigTree(row) {
      this.$refs.definitionTable.clearSelection();
      this.$refs.definitionTable.toggleRowSelection(row);
      this.RTitle = row.caliberName
    },
    // 查询
    searchFunc(){
      console.log("调用了search")
    },
    // 口径定义弹窗表的查询
    searchFFunc(){
      console.log("searchFFunc")

    },
    addFunc() {
      this.saveFlg = 1;
      for (let k in this.saveForm) {
        this.saveForm[k] = "";
      }
      this.addOrEdit = true;
    },
    editFunc() {
      this.saveFlg = 2;
      let selection = this.$refs.multipleTable.selection;
      if (selection.length != 1) {
        return this.$message.warning("请选择一条数据进行修改");
      }
      let row = selection[0];
      let form = {
        caliberProjectCode: row.caliberProjectCode,
        caliberProjectName: row.caliberProjectName,
        moduleCode: row.moduleCode
      };
      this.saveForm = form;
      this.addOrEdit = true;
    },
    deleteFunc() {
      let selection = this.$refs.multipleTable.selection;
      if (selection.length < 1) {
        return this.$message.warning("请选择要删除的数据");
      }
      this.$confirm("你确认要删除吗？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.$message.success("success");
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    },
    configFun() {
      let checked = this.$refs.multipleTable.selection;
      if (checked.length < 1) {
        return this.$message.warning("请选择一条数据");
      } else if (checked.length > 1) {
        return this.$message.warning("只能选择一条数据");
      } else {
        this.isConfigDialog = true;
      }
    },
    // 口径定义表新增
       addFuncInner(){
      
      this.saveFlgInner = 1;
      for (let k in this.saveFormInner) {
        this.saveFormInner[k] = "";
      }
      this.isScopeDialog = true;
    },
    // 口径定义表编辑
    editFuncInner() {
      this.saveFlgInner = 2;
      let selection = this.$refs.definitionTable.selection;
      if (selection.length != 1) {
        return this.$message.warning("请选择一条数据进行修改");
      }
      let row = selection[0];
      this.saveFormInner = {...row};
      this.saveFormInner.caliberProjectCode = row.caliberProject.caliberProjectCode
      this.isScopeDialog = true;
    },
    // 口径定义表删除
    deleteFuncInner() {
      let selection = this.$refs.definitionTable.selection;
      if (selection.length < 1) {
        return this.$message.warning("请选择要删除的数据");
      }
      this.$confirm("你确认要删除吗？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.$message.success("success");
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    },
  //口径定义规则保存
  saveRuleDefFunc(){
    console.log(this.ruleDefList)
  },
    // 口径定义规则新增
    addRuleData(){
      this.ruleDefShow = true

    },
    // 口径定义规则编辑操作
    editRuleData(row){
      console.log(row,"edit")
      this.ruleDefShow = true
    },
    deleteRuleData(row){
      console.log(row,"delete")
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    }
  }
};
</script>

<style lang="scss" scoped>
</style>